package main.Parallel;

public abstract class IterationOperation<E> {
    protected int length;
    protected int progress;
    
    protected IterationOperation(int length) {
        this.progress = 0;
        this.length = length;
    }
    
    public synchronized void addProgress() {
        this.progress++;
    }
    
    public synchronized boolean isDone() {
        return this.progress >= this.length;
    }
    
    public void join() {
        while(!isDone());
    }
    
    public abstract void runIterationOperation(int index, E val);
}
